package com.example.hr.text_android.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.hr.text_android.R;
import com.example.hr.text_android.adapter.AdapterOne;
import com.example.hr.text_android.entity.Status;

import java.util.ArrayList;

/**
 * Created by hr on 2017/7/24.
 */
public class fragment1 extends Fragment {
    private RecyclerView recyclerView;
    private AdapterOne adapterOne;
    private ArrayList<Status> mDataList;
    private static final String[] TITLE = {"Animation", "MultipleItem", "Header/Footer", "PullToRefresh",
            "Section", "EmptyView", "DragAndSwipe", "ItemClick", "ExpandableItem", "DataBinding", "UpFetchData"};
    private static final String[] ACTIVITY = {"Animation1", "MultipleItem1", "Header/Footer1", "PullToRefresh1", "Section1",
            "EmptyView1", "DragAndSwipe1", "ItemClick1", "ExpandableItem1", "DataBinding1", "UpFetchData1"};

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//        return super.onCreateView(inflater, container, savedInstanceState);
        View view = inflater.inflate(R.layout.fragment_one, container, false);
        recyclerView = ((RecyclerView) view.findViewById(R.id.fragment1_recycle_view));
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(linearLayoutManager);
        initData();
        initAdapter();
        return view;
    }

    private void initAdapter() {
        adapterOne = new AdapterOne(mDataList);
        recyclerView.setAdapter(adapterOne);
    }

    private void initData() {
        mDataList = new ArrayList<>();
        for (int i = 0; i < TITLE.length; i++) {
            Status item = new Status();
            item.setUserName(TITLE[i]);
            item.setText(ACTIVITY[i]);
            mDataList.add(item);
        }
    }
}
